import Page from '../../../../vue-common/models/Page';
import BaseModule from './base-module'
import Ajax from '../../lib/ajax'

class WebsiteInfoModule extends BaseModule{
    state={
        info: {},
        aboutUs: {},
        companyProfile: {},
        corporateCulture: {},
        honor: {},
        userNotice: {},
        userAgreement: {},
        contactUs: {},
        friendlyLinks: [],
        couponPage: new Page('/api/services/app/Coupon/Search'),
        articlePage: new Page('/api/services/app/Article/SearchEnabled'),
        feedbackPage: new Page('/api/services/app/Feedback/SearchAudited'),

        homeIndex: {
            companyProfile: {},
            honor: {
                pictures: []
            },
            commodities: [],
            articles: [],
            advertisements: [],
            notices: []
        },
        homeFooter: {
            companyProfile: {},
            aboutUs: {},
            websiteInfo: {},
            companyInfo: {},
            friendlyLinks: []
        }
        
    }
    actions={
        async getAboutUs(context){
            var response = await Ajax.get('/api/services/app/WebsiteInfo/GetAboutUs');
            context.state.aboutUs = response.data.result;
        },
        async getCompanyProfile(context){
            var response = await Ajax.get('/api/services/app/WebsiteInfo/GetCompanyProfile');
            context.state.companyProfile = response.data.result;
        },
        async getCorporateCulture(context){
            var response = await Ajax.get('/api/services/app/WebsiteInfo/GetCorporateCulture');
            context.state.corporateCulture = response.data.result;
        },
        async getHonor(context){
            var response = await Ajax.get('/api/services/app/WebsiteInfo/GetHonor');
            context.state.honor = response.data.result;
        },
        async getUserNotice(context){
            var response = await Ajax.get('/api/services/app/WebsiteInfo/GetUserNotice');
            context.state.userNotice = response.data.result;
        },
        async getUserAgreement(context){
            var response = await Ajax.get('/api/services/app/WebsiteInfo/GetUserAgreement');
            context.state.userAgreement = response.data.result;
        },
        async getContactUs(context){
            var response = await Ajax.get('/api/services/app/WebsiteInfo/GetContactUs');
            context.state.contactUs = response.data.result;
        },
        async getFriendlyLink(context){
            var response = await Ajax.get('/api/services/app/WebsiteInfo/GetFriendlyLink');
            context.state.friendlyLinks = response.data.result;
        },
        async getHomeIndex(context){
            var response = await Ajax.get('/api/services/app/Home/GetIndex');
            context.state.homeIndex = response.data.result;
        },
        async getHomeFooter(context){
            var response = await Ajax.get('/api/services/app/Home/GetFooter');
            context.state.homeFooter = response.data.result;
        }
    };
    mutations={
    }
}

const websiteInfo = new WebsiteInfoModule();
export default websiteInfo;